import request from "./useRequests";
import { userinfo } from '@/stores/counter'
import { ElMessage } from 'element-plus'

export default function getMyEnrollNotice() {
    const user = userinfo()
    async function gettingMyEnrollNotice() {
        try {
            const res = await request({
                method: "get",
                url: `/user/getMyEnrollNotice`,
            })
            let data = res.data.data.list
            user.enrolledNotices = []
            // 遍历 data，将 noticeId push 到 enrolledNotices 中
            for (let i = 0; i < data.length; i++) {
                user.enrolledNotices.push(data[i].noticeId)
            }
        } catch (err: any) {
            //alert(err)
        }
    }

    return {
        gettingMyEnrollNotice
    }
}